<?php
namespace Admin\Controller;
use Think\Controller;
class IndexController extends Controller {
    public function index(){

	    //if(!IS_POST){$this->error('未登录','login');}
	    //if(!isset($_SESSION)){$this->error('未登录','login',1);}
	    //if(!I('session.username')=='samuel'){$this->error('未登录','/index.php/Admin/login',1);}

	    $this->display();
    }

    public function insert(){

	    //echo I('session.username');die;
	    if(I('session.username')!='samuel'){$this->error('未登录','/index.php/Admin/login',1);}

	    $this->display();

	    }

    public function insertd(){

	    //$data['title']=I('title');
	    //$data['content']=I('content');
	    if(!IS_POST){$this->error('未登录','Login',1);}
	    $data=I();
	    $data['time']=date('Y-m-d');
	    //p($data);die;

	    $User = M('Content');
	    //$User->create($data);
	    if($User->add($data)) {

		    $this->success('成功','index');
	    }

	    else
	    {
		    $this->error('失败');

	    }
 
	     
    }

    public function delete() {

	    if($delete = M('Content')->where('id>0')->delete()){
		    $this->success('删除了'.$delete.'条数据');
	    }
    }
    public function logout() {

	    session_destroy(); 
	    $this->success('退出成功','/index.php/Home/index');

	    }
	     
}
